package com.example.shop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.shop.domain.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface UserMapper extends BaseMapper<User> {
   public User findUserByName(String username);

    @Select({
            "<script>",
            "select *",
            "from t_user",
            "<where>",
            "<if test='user.username != null'>",
            "and username like CONCAT('%', #{user.username}, '%')",
            "</if>",
            "</where>",
            "</script>"
    })
    List<User> selectAllUser(@Param("user") User user);

}
